package laserdancer.smart.com.criminalintent;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;

import butterknife.ButterKnife;

/**
 * Created by ares on 2018/1/30.
 */

public abstract class SingleFragmentActivity extends AppCompatActivity {
    protected abstract Fragment createFragment();

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_crime);
        ButterKnife.bind(this);

        FragmentManager manager = getSupportFragmentManager();
        Fragment _fragment = manager.findFragmentById(R.id.fragmentContainer);

        if(_fragment == null){
            _fragment = createFragment();
            manager.beginTransaction().add(R.id.fragmentContainer,_fragment)
                    .commit();
        }
    }
}
